<template>
  <div class="home">
    <my-tree :data="data" @dataset="getdata" :diectoryDrop="diectoryDrop" :fileDrop="fileDrop" :delete="deleteDrop"></my-tree>
  </div>
</template>

<script>
import { getTreeList } from "../http.js";
import MyTree from '@/components/MyTree'
export default {
  name: 'Home',
  data() {
    return {
      data:[],
      fileDrop:[
        {text:'rm',value:"删除文件"}
      ],
      diectoryDrop:[
        {text:'rn',value:"修改名字"},
        {text:'rm',value:"删除文件夹"}
      ]
    }
  },
  components: {
    MyTree
  },
  mounted() {
    
  },
  created() {
    this.feach()
  },
  methods: {
    getdata(e){
      console.log(e,'eeee');
      this.data=e
    },
    async feach(){
      let {data}=await getTreeList();
      //递归数据
      data.parent.forEach(p=>p.type='parent')
      let AllData=[...data.parent,...data.child]
      this.data=AllData
    },
    deleteDrop(){//返回一个promise
      return new Promise((resolve)=>{
        setTimeout(() => {
          resolve('')
        }, 3000);
      })
    }
  },
}
</script>
